home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SAVESCRN.SWG / 0014_Fully Compatible Screen Saving.pas < prev   
Pascal/Delphi Source File  |  1995-03-03  |  3KB  |  84 lines

  1. {
  2. > Can anyone tell me (or give me the source code) how I can grab
  3. > a screen in textmode and put it later back on the screen.
  4.  
  5. If you want your software to be compatible, use the following procedures,
  6. functions and structs:
  7. }
  8.  
  9. const
  10.   MaxScr=25;
  11.  
  12. type
  13.   ScrRec=record Ptr:pointer; Size:word; end;
  14.   ScrType=array[1..MaxScr] of ScrRec;            { Pointers to saved screens }
  15.  
  16. var
  17.   Screen:ScrType;
  18.   ScrCtr:byte;                                       { Index to saved screen }
  19.   v_vidseg:word;                               { Segmentaddress of video-RAM }
  20.   v_pageinmem:boolean;                          { screenpage saved in memory }
  21.  
  22. { current number of rows }
  23. function rows:byte;
  24. var tmp:byte;
  25. begin
  26.   tmp:=mem[$40:$84]+1;
  27.   if tmp<25 then rows:=25 else rows:=tmp;
  28. end;
  29.  
  30. { current number of columns }
  31. function cols:byte;
  32. var tmp:byte;
  33. begin
  34.   tmp:=mem[$40:$4a];
  35.   if tmp<80 then cols:=80 else cols:=tmp;
  36. end;
  37.  
  38. { save screen }
  39. procedure setscr;
  40. begin
  41.   Screen[ScrCtr].Size:=Rows*Cols*2;
  42.   getmem(Screen[ScrCtr].Ptr,Screen[ScrCtr].Size);
  43.   move(mem[v_vidseg:0],Screen[ScrCtr].Ptr^,Screen[ScrCtr].Size);
  44.   inc(ScrCtr);
  45.   v_pageinmem:=true;
  46. end;
  47.  
  48. { restore last screen }
  49. procedure getscr;
  50. begin
  51.   if ScrCtr>1 then begin
  52.     dec(ScrCtr);
  53.     move(Screen[ScrCtr].Ptr^,mem[v_vidSeg:0],Screen[ScrCtr].Size);
  54.     freemem(Screen[ScrCtr].Ptr,Screen[ScrCtr].Size);
  55.   end else v_pageinmem:=false;
  56. end;
  57.  
  58. { determine video-segment: }
  59. begin
  60.   Regs.ah:=15;                                    { Define actual video-mode }
  61.   intr($10,Regs);                                { Call BIOS video-interrupt }
  62.   if Regs.al=7 then v_vidseg:=$b000                       { Monochrome mode? }
  63.   else v_vidseg:=$b800;                                      { No, Colormode }
  64.   v_pageinmem:=false;
  65. end.
  66.  
  67. {
  68. If you want to create louzy software, which is not compatible at all, use an
  69. array like:
  70. vidmem:array[1..25,1..80] of record ch:char; attr:byte; end; absolute
  71. $b800:0000;
  72. This array will _ONLY_ work in color-mode on a 25x80 screen. The above
  73. procedures work in _EVERY_ (!) text-mode.
  74. If you've setup everything correctly (just do the determine-stuff), then you
  75. can save a screen by using 'setscr', and restore the screen by 'getscr'. Those
  76. two must be in balance. If you placed some windows on the screen (and saved all
  77. the screens), and an error accurs, you can clear the memory by something like:
  78. while v_pageinmem do getscr;
  79. MaxScr is not the number of lines (25), but the maximum number of screens which
  80. can be saved. If you need more or less, set it to something appropriate, but
  81. use some slack: the structs hardly cost memory (especialy if you compare it
  82. with the array-type). _    _
  83. }
  84.